<%@page import="javax.swing.RepaintManager"%>
<%@page import="subject.Subject"%>
<%@page import="subject.SubjectDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>新增课程处理页面</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
    <%
    	request.setCharacterEncoding("utf-8");
    	String	subjectname=request.getParameter("subjectname");
    	int classhour=0;
    	String classhourStr=request.getParameter("classhour");
    	if(classhourStr != null && !classhourStr.equals("") && !classhourStr.equals("null"))
    	{
    		classhour=Integer.parseInt(classhourStr.trim()) ;
    	}
    	int gradeid=0;
    	String gradeidStr=request.getParameter("gradeid");
    	if(gradeidStr != null && !gradeidStr.equals("") && !gradeidStr.equals("null"))
    	{
    		gradeid=Integer.parseInt(gradeidStr.trim());
    	}
    	Subject sb=new Subject();
		sb.setSubjectname(subjectname);
		sb.setClasshour(classhour);
		sb.setGradeid(gradeid);
    	SubjectDao sbDao=new SubjectDao();
    	int result=sbDao.add(sb);
    	if(result==1)
    	{
    		response.sendRedirect("subjectlist.jsp");
   	}
    	else
    	{
     		response.sendRedirect("addSubject.jsp");
   	}
     %>
  </body>
</html>
